package com.example.demo.utils;

import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;

import java.nio.charset.StandardCharsets;


@Component
public class MD5Util {
    public static String MD5(String src)
    {
        String key = DigestUtils.md5DigestAsHex(src.getBytes(StandardCharsets.UTF_8));
        return key;
    }
    public static final String salt = "c1a2o3y4u5q6i7";
    public static String inputPassStr(String src)
    {
        String result = salt.charAt(0)+MD5(src)+salt.charAt(5)+salt.charAt(9);
        return result;
    }
    public static String DBPassStr(String src)
    {
        String result = salt.charAt(9)+MD5(src)+salt.charAt(1)+salt.charAt(8);
        return result;
    }
    public static String MD5twice(String src)
    {
        String first = inputPassStr(src);
        String second = DBPassStr(first);
        return second;
    }

    public static void main(String[] args) {
        System.out.println("加密前:c8918833");
        System.out.println("加密后:"+MD5twice("c8918833"));
    }
}
